
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function checkAdd(){
		var empno = document.getElementById("empno").value;
		var ename = document.getElementById("ename").value;
		var job = document.getElementById("job").value;
		var hiredate= document.getElementById("hiredate").value;
		if(empno== ""){
			document.getElementById("s1").innerHTML="<font color='red'>员工编号不能为空</font>";
			return false;
		}else if(ename== ""){
			document.getElementById("s2").innerHTML="<font color='red'>员工姓名不能为空</font>";
			return false;
		}else if(job== ""){
			document.getElementById("s3").innerHTML="<font color='red'>工作岗位不能为空</font>";
			return false;
		}else if(hiredate== ""){
			document.getElementById("s4").innerHTML="<font color='red'>入职日期不能为空</font>";
			return false;
		}else{
			return ture;
		}
	}
	
	function checkHiredate() {
		var hiredate=document.getElementById("hiredate").value;
		reg=/\d{4}-\d{2}-\d{2}/;
		if(reg.test(hiredate)==false){
			alert("亲，日期格式有错(⊙o⊙)哦");
		}
	}


</script>
</head>
<body>
<form action="../addEmp" method="post" onsubmit="return checkAdd()">
	<table>
		<tr>
			<td>员工编号：<input type="text" name="empno" id="empno">
			<span id="s1"></span>
			</td>
		</tr>
		<tr>
			<td>员工姓名：<input type="text" name="ename" id="ename">
			<span id="s2"></span>
			</td>
		</tr>
		<tr>
			<td>员工岗位：<input type="text" name="job" id="job">
			<span id="s3"></span>
			</td>
		</tr>
		<tr>
			<td>入职日期：<input type="text" name="hiredate" id="hiredate" onblur="checkHiredate()">
			<span id="s4"></span>
			</td>
		</tr>
		<tr>
			<td style="float: left"><input type="submit" value="添加"></td>
			<td style="float: left"><input type="reset" value="清空"></td>
		</tr>

	</table>
</form>

</body>
</html>